package interrogation;

import java.util.List;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class FindByElements {
	static String url;
	static WebDriver driver;
	@BeforeClass
	public static void setUp() throws Exception {
		
		url  = "http://www.compendiumdev.co.uk/selenium/find_by_playground.php";
		driver = new FirefoxDriver();
		driver.get(url);
		
	}

	@AfterClass
	public static void tearDown() throws Exception {
		driver.quit();
	}

	@Test
	public void testFindByElements() {
		//If no web element returns by driver.findelements
		//No exception thrown
		List<WebElement> elementList = driver.findElements(By.id("bob"));
		System.out.println(elementList.size());
		
	}
	@Test
	public void testFindByElement() {
		//If no web element returns by driver.findelement
		//Exception thrown
		//So it needs to be handled with try catch blocks
		try{WebElement elementList = driver.findElement(By.id("bob"));}
		catch(NoSuchElementException e){}
				
	}

}
